package cn.easybuy.web.pre;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import cn.easybuy.entity.News;
import cn.easybuy.service.NewsService;
import cn.easybuy.service.impl.NewsServiceImpl;

public class NewsInfoServlet extends HttpServlet{

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id=request.getParameter("id");
		NewsService ns=new NewsServiceImpl();
		PrintWriter out=response.getWriter();
		List<News> list=ns.getNewsById(Integer.parseInt(id));
		String newsJSON=JSON.toJSONStringWithDateFormat(list, "yyyy-MM-dd");
		out.print(newsJSON);
		out.flush();
		out.close();
	}

}
